//
//  YAYITagGroupCell.m
//  yayi-医生版
//
//  Created by Veer on 16/4/29.
//  Copyright © 2016年 Veer. All rights reserved.
//

#import "YAYITagGroupCell.h"
#import "YAYITagGroupItem.h"

@interface YAYITagGroupCell()

@property (nonatomic, weak) UILabel *tagNameLbl;
@property (nonatomic, weak) UILabel *detailLbl;
@property (nonatomic, weak) UIView *bottomLineView;

@end

@implementation YAYITagGroupCell

- (void)setItem:(YAYITagGroupItem *)item
{
    _item = item;
    
    self.tagNameLbl.text = [NSString stringWithFormat:@"%@(%ld)", item.tagname, item.clientcount];
    self.detailLbl.text = item.clientnames;
}

+ (instancetype)cellWith:(UITableView *)tablevie
{
    static NSString *cellID = @"tagGroupCell";
    
    YAYITagGroupCell *cell = [tablevie dequeueReusableCellWithIdentifier:cellID];
    
    if (nil == cell) {
        cell = [[YAYITagGroupCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setupSubView];
    }
    return self;
}


- (void)setupSubView
{

    // tagNamelabel
    UILabel *tagNameLbl = [[UILabel alloc] init];
    tagNameLbl.text = @"阿华";
    tagNameLbl.font = [UIFont systemFontOfSize:15];
    tagNameLbl.textColor = YAYIColor(89, 88, 88);
    [self.contentView addSubview:tagNameLbl];
    self.tagNameLbl = tagNameLbl;
    
    // 名字label
    UILabel *detailLbl = [[UILabel alloc] init];
    detailLbl.text = @"潘志文，小黄";
    detailLbl.font = [UIFont systemFontOfSize:14];
    detailLbl.textColor = YAYIColor(169, 164, 163);
    [self.contentView addSubview:detailLbl];
    self.detailLbl = detailLbl;
    

    // 底部线
    UIView *bottomLineView = [[UIView alloc] init];
    bottomLineView.backgroundColor = YAYICellLineColor;
    [self.contentView addSubview:bottomLineView];
    self.bottomLineView = bottomLineView;
}


- (void)layoutSubviews
{
    [super layoutSubviews];

    
    [self.tagNameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(15);
        make.bottom.equalTo(self.contentView.mas_centerY).offset(-3);
    }];
    
    [self.detailLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(15);
        make.top.equalTo(self.contentView.mas_centerY).offset(3);
    }];
    
    [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@0.5);
        make.width.equalTo(@(SCREEN_width));
        make.bottom.equalTo(self.contentView).offset(0);
        make.left.equalTo(self.contentView);
    }];
}
@end
